package storageManager;
import java.util.ArrayList;


public class DataRecord extends Record{
	public int status;
	public ArrayList<String> values;
	public DataRecord(){
		
	}
	public DataRecord(int status, ArrayList<String> values){
		this.status = status;
		this.values = values;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public ArrayList<String> getValues() {
		return values;
	}
	public void setValues(ArrayList<String> values) {
		this.values = values;
	}
	public byte[] toByte(TableRecord tableRecord){//Parse the record object to a byte array
		int numOfFields = values.size();
		int sizeOfADataRecord = tableRecord.getSizeOfADataRecord();
		byte[] bytes = new byte[sizeOfADataRecord];
		bytes[0] = (byte) status;
		int offset = 1;
		for(int i=0;i<numOfFields;i++){
			String tempValue = values.get(i);
			int sizeOfValue = tableRecord.getFieldSizes().get(i);
			int tempSize = tableRecord.getFieldSizes().get(i);
			System.arraycopy(Tools.stringToByte(tempValue,sizeOfValue), 0, bytes, offset, tempValue.length());
			offset += tempSize;
		}
		return bytes;
	}
}
